package SocketTool;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class FileServer {
	public static void main(String[] args) {
		try {
			System.out.println("服务器开启");
			ServerSocket s = new ServerSocket(6355);
			Socket socket = s.accept();
			InputStream input = socket.getInputStream();
			OutputStream output = new FileOutputStream("e:\\b\\b.txt");
			byte[] buffer = new byte[1000];
			String str = "";
			int len = 0;
			while ((len = input.read(buffer)) != -1) {
				output.write(buffer, 0, len);
			}
			System.out.println("写文件完成！");
			s.close();
			input.close();
			output.flush();
			output.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
